#include "globalData.h"

#define WEIGHT_FILE "weights.bin"

#define TERMINAL_DIFF_WEIGHT 500
#define WIN_WEIGHT 1000000
#define NUM_FEATURES 18

/* we only have 92 stages of the game - from when there are 5 to 96 pieces */
#define NUM_STAGES 92

/* the weight for each feature */
struct Weights
{
    float disc_feature[15];
    float mobility;
    float frontier;
    float disc_diff;
};

/* the value for each feature */
struct Feature_Values
{
    int disc_feature[15];
    int mobility;
    int frontier;
    int disc_diff;
};

/* weights for different stages */
extern Weights WEIGHTS[NUM_STAGES];

/* evaluate the gameState
   #in#  gs             ... current gameState
   #in#  player         ... current player
   #ret#                ... integer value of the gameState,
                            positive means favouring WHITE                  */
int evaluateGame(gameState gs, BoardState player, int stage);

/* evaluate a terminal state */
int evaluateTerminal(gameState gs);


/* evaluate the gameState using pre-computed feature values */
float evaluateGameL(Feature_Values v, int stage);

/* get the value of each feature */
Feature_Values GetFeatureValue(gameState gs);

/* evaluate the given player's number of moves
   #in#  gs             ... current gameState
   #in#  player         ... current player
   #ret#                ... number of moves the player has                  */
int evaluateMobility(gameState gs, BoardState player);


/* count the number of frontier discs (discs next to empty squares)
   #in#  self           ... bitboard for the color we are evaluating
   #in#  empty          ... bitboard of empty squares
   #ret#                ... number of frontier discs                        */
int evaluateFrontier(BitBoard self, BitBoard empty);

/* evaluate difference between number of stable discs
   #in#  gs             ... current gameState
   #ret#                ... white_stable - black_stable                     */
int evaluateStabilityDiff(gameState gs);

/* calculate the how many more pieces white has over black */
int evaluatePieceDiff(gameState gs);

/* initialise weights by reading from a file
   set up memory used to store the game information                         */
void initialiseEvaluator();

/* write weights back into file */
void writeWeights(char * file = NULL);
